<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="${pageContext.request.contextPath }/bootstrap/img/favicon.ico">
<link href="${pageContext.request.contextPath }/bootstrap/css/style.min.css?v=4.0.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrap/css/animate.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrap/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
<link href="${pageContext.request.contextPath}/bootstrap/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrap/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/bootstrap/css/jquery-confirm.css"/>
<link href="${pageContext.request.contextPath }/bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath }/bootstrapStyle/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet"/>
<title>医院端管理-审核</title>
</head>
<body>
	<div class="panel panel-default">
	    <div class="panel-body form-group" style="margin-top: 0px;">
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">所属城市：</label>
	        <div class="col-sm-2">
	            <select class="form-control" name="hospadrprovince" id="hospadrprovince1" onchange="loadcity()">
					<option value="0">---请选择省---</option>
				</select>
	        </div>
	        <div class="col-sm-2">
	            <select class="form-control" name="hospadrcity" id="hospadrcity1" onchange="loadarea()">
					<option value="0">---请选择市---</option>
				</select>
	        </div>
	        <div class="col-sm-2">
	            <select class="form-control" name="hospadrarea" id="hospadrarea1">
					<option value="0">---请选择县（区）---</option>
				</select>
	        </div>
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">医院等级：</label>
	        <div class="col-sm-2">
	            <select class="form-control" name="hosplevel" id="hosplevel1">
					<option value="">全部</option>
				</select>
	        </div>
	    </div>
	    <div class="panel-body form-group" style="margin-top: 0px;">
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">注册手机号：</label>
	        <div class="col-sm-2">
	            <input type="text" class="form-control" name="hosploginphone" id="hosploginphone1"/>
	        </div>
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">审核提交时间：</label>
	        <div class="col-sm-3 form-group">
                <div class="input-daterange input-group" id="datepicker">
                    <input type="text" class="input-md form-control" id="startdatetime" name="startdatetime" value="" />
                    <span class="input-group-addon">到</span>
                    <input type="text" class="input-md form-control" id="enddatetime" name="enddatetime" value="" />
                </div>
            </div>
	        <div class="col-sm-1 control-label">
	            <button class="btn btn-primary" id="search_btn">查询</button>
	        </div>
	     </div>
	</div>
	<!-- 动态加载table -->
	<table id="hospitaltabExamine" class="table table-hover"></table>

	<div class="modal inmodal fade" id="agreeModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog modal-lg">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">用户审核</h4>
               	</div>
                <div class="modal-body">
                <input type="hidden" id="hosploginid" />
                	<div class="form-group draggable">
						<label class="control-label">是否同意*</label>
						<select class="form-control" name="isagree" id="isagree" required="" aria-required="true" onchange="isagree()">
							<option value="true">同意</option>
							<option value="false">不同意</option>
						</select>
					</div>
					<div class="form-group draggable">
						<label class="control-label">审核意见*</label>
						<textarea id="idea" rows="4" onkeyup="words_deal('idea');" name="idea" class="form-control" placeholder="输入审核意见，意见会作为推送发送给用户！"></textarea>
					</div>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                	<button type="button" class="btn btn-primary" onclick="ExamineSubmit()" id="SHBtn">提交</button>
           		</div>
           	</div>
        </div>
	</div>
	<div class="modal inmodal fade" id="HospitalDetailsModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog" style="width: 1200px">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">用户详情</h4>
               	</div>
                <div class="modal-body">
                	<div class="wrapper wrapper-content">
        				<div class="row animated fadeInRight">
                    		<div class="col-sm-4">
                				<div class="ibox float-e-margins">
                    				<div class="ibox-title">
				                        <h4>个人登陆资料</h4>
				                    </div>
				                    <div>
				                    	<div class="ibox-content profile-content">
			                    			<img alt="image" id="hosploginpix" style="max-width:100px" class="img-rounded" src="${pageContext.request.contextPath}/bootstrap/img/a5.jpg">
			                    		</div>
			                    		<div class="ibox-content profile-content">
			                    			<p><i class="fa fa-user"> 登陆手机号码：</i><strong><a id="hosploginphone"></a></strong></p>
				                            <hr/>
				                            <p><i class="fa fa-user"> 登陆账号审核状态：</i><strong><a id="hosplogintypename"></a></strong></p>
				                            <hr/>
				                            <p><i class="fa fa-map-marker"> 上次登陆时间：</i><strong><a id="hosplogintime"></a></strong></p>
				                            <hr/>
			                    		</div>
				                    </div>
				                </div>
				        	</div>
				        	<div class="col-sm-8">
                				<div class="ibox float-e-margins">
                    				<div class="ibox-title">
				                        <h4>个人详细信息</h4>
				                    </div>
				                    <div class="ibox-content">
			                    		<div class="row">
			                    			<div class="col-sm-6">
			                    				<p><i class="fa fa-user"> 医院名称：</i><strong><a id="hospname"></a></strong></p>
												<hr/>
						                    	<p><i class="fa fa-credit-card"> 身份证号码：</i><strong><a id="hospregidcard"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在地址：</i><strong><a id="address1"></a></strong></p>
						                 		<hr/>
			                    			</div>
			                    			<div class="col-sm-6">
			                    				<p><i class="fa fa-user"> 联系电话：</i><strong><a id="hospphone"></a></strong></p>
						                    	<hr/>
						                    	<p><i class="fa fa-user"> 医院等级：</i><strong><a id="hosplevelname"></a></strong></p>
						                    	<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在区和路：</i><strong><a id="address2"></a></strong></p>
						                 		<hr/>
			                    			</div>
			                    			<div class="col-sm-12">
			                    				<p><i class="fa fa-info"> 医院介绍：</i><strong><a id="hospabs"></a></strong></p>
		                 						<hr/>
						                 		<p><i class="fa fa-info"> 医院特色介绍：</i><strong><a id="hospfeature"></a></strong></p>
						                 		<hr/>
			                    			</div>
			                    			<!-- 显示照片 -->
			                    			<div id="photoPanel">
			                    				
			                    			</div>
			                    		</div>
				                    </div>
				                </div>
				        	</div>
        				</div>
        			</div>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
           		</div>
           	</div>
        </div>
	</div>
	
    <script src="${pageContext.request.contextPath }/bootstrap/js/jquery.min.js?v=2.1.4"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/jquery-confirm.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/moment-with-locales.min.js"></script>
	<script src="${pageContext.request.contextPath }/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
	<script src="${pageContext.request.contextPath }/bootstrapStyle/js/plugins/fancybox/jquery.fancybox.js"></script>
    <script>
  //根据窗口调整表格高度
    $(window).resize(function() {
        $('#hospitaltabExamine').bootstrapTable('resetView', {
            height: tableHeight()
        })
    })
    //查询按钮事件
    $('#search_btn').click(function(){
        $('#hospitaltabExamine').bootstrapTable('refresh');
    })
    //tableHeight函数
    function tableHeight(){
        //可以根据自己页面情况进行调整
        return $(window).height();
    }
  	function refreshTab(){
  		$('#hospitaltabExamine').bootstrapTable('refresh');
  	}
	//生成用户数据
    $('#hospitaltabExamine').bootstrapTable({
        method: 'get',
        contentType: "application/x-www-form-urlencoded",//必须要有！！！！
        url:"${pageContext.request.contextPath}/Main/Hospital/hospitalListAjax.action",//要请求数据的文件路径
        height:tableHeight(),//高度调整
        striped: true, //是否显示行间隔色
        dataField: "rows",//bootstrap table 可以前端分页也可以后端分页，这里
        //我们使用的是后端分页，后端分页时需返回含有total：总记录数,这个键值好像是固定的  
        //rows： 记录集合 键值可以修改  dataField 自己定义成自己想要的就好
        pageNumber: 1, //初始化加载第一页，默认第一页
        pagination:true,//是否分页
        queryParamsType:'limit',//查询参数组织方式
        queryParams:function(params) {//自定义参数，这里的参数是传给后台的，我这是是分页用的    
            return {//这里的params是table提供的    
                offset : params.offset,//从数据库第几条记录开始    
                limit : params.limit,
                type:2,
                hospadrprovince:$('#hospadrprovince1').val(),
                hospadrcity:$('#hospadrcity1').val(),
                hospadrarea:$('#hospadrarea1').val(),
                hosplevel:$('#hosplevel1').val(),
                hosploginphone:$('#hosploginphone1').val(),
                startdatetime:$('#startdatetime').val(),
                enddatetime:$('#enddatetime').val()
            //找多少条    
            };},//请求服务器时所传的参数
        sidePagination:'server',//指定服务器端分页
        pageSize:10,//单页记录数
        pageList:[1,5,10,30,50,100],//分页步进值
        showRefresh:true,//刷新按钮
        showColumns:true,
        clickToSelect: true,//是否启用点击选中行
        toolbarAlign:'right',//工具栏对齐方式
        buttonsAlign:'right',//按钮对齐方式
        toolbar:'#toolbar',//指定工作栏
        columns:[
        	{
                title:'全选',
                field:'select',
                //复选框
                checkbox:true,
                width:25,
                align:'center',
                valign:'middle'
            },
            {
                title:'医院端登陆ID',
                field:'hosploginid'
            },
            {
                title:'医院名称',
                field:'hospname'
            },
            {
                title:'医院等级',
                field:'hosplevelname'
            },
            {
                title:'医院端登陆手机号',
                field:'hosploginphone'
            },
            {
                title:'医院账户状态',
                field:'hosplogintypename'
            },
            {
                title:'操作',
                field:'hosplogintype',
              	//列数据格式化
                formatter:operate
            },
        ],
        locale:'zh-CN',//中文支持,
        responseHandler:function(rows){
            //在ajax获取到数据，渲染表格之前，修改数据源
            return rows;
        }
    })
    //操作序列规则化
	function operate(value,row,index){
		// data-toggle="modal" data-target="#agreeModal"
		if(value==2){
			return '<button class="btn btn-danger" style="height:30px" data-toggle="modal" data-target="#agreeModal" onclick="Examine('+row.hosploginid+')">审核</button>&nbsp&nbsp<button class="btn btn-primary" style="height:30px" onclick="Details('+row.hosploginid+')">详情</button>';
	    }else{
		    return '<button class="btn btn-primary" style="height:30px" data-toggle="modal" data-target="#DetailsModal" onclick="Details('+row.hosploginid+')">详情</button>';
	    }
	}
	function Examine(hosploginid){
		//alert(docloginid);
		$('#hosploginid').val(hosploginid);
	}
	function ExamineSubmit(){
		var hosploginid = $('#hosploginid').val();
		var isagree = $('#isagree').val();
		var idea=$("#idea").val().replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+$)/g, "");
		//alert("hosploginid="+hosploginid+"&isagree="+isagree+"&idea="+idea);
		$.confirm({
		    title: '提示!',
		    content: '你确定提交审核？',
		    type: 'blue',
		    typeAnimated: true,
		    buttons: {
		    	确定: function () {
		    		$("#SHBtn").html('<i class="fa fa-spinner fa-spin"></i>处理中...');
		    		$("#SHBtn").prop('disabled',true);
		    		$.ajax({
		        		type:'post',
		        		url:"${pageContext.request.contextPath}/Main/Hospital/hospitalexamineSubmit.action",
		        		data:"hosploginid="+hosploginid+"&isagree="+isagree+"&idea="+idea,
		        		async: true,
		        		success:function(data){
		        			$("#SHBtn").html('提交');
	    		    		$("#SHBtn").prop('disabled',false);
		        			$.alert(data.msg);
		        			if(data.code==100){
		        				$('#agreeModal').modal('hide');
		        				refreshTab();
		        			}
		        		},error:function(request){
		        			$.alert("向服务器请求失败！");
		        			$("#SHBtn").html('提交');
	    		    		$("#SHBtn").prop('disabled',false);
		        		}
		        	})
		    	},
				取消: function () {},
		    }	
		});
	}
	function Details(hosploginid){
		//alert(hosploginid);
		$.ajax({
			type:"post",
			url:"${pageContext.request.contextPath}/Main/Hospital/getHospitalDetails.action",
			data:"hosploginid="+hosploginid,
			async: true,
    		success:function(data){
    			//alert("data.details.docname="+data.details.docname);
    			if(data.code==100){
    				$('#HospitalDetailsModal').modal('show');
    				ModalPadding(data.details);
    			}else{
    				$.alert(""+data.msg);
    			}
    		},error:function(request){
    			
    		}
		})
	}
    function ModalPadding(data){
    	$("#hosploginpix").attr('src',data.hosploginpix);//登陆头像
		$("#hosploginphone").html(data.docloginphone);//登录手机号码
		$("#hosplogintypename").html(data.doclogintypename);//账号登陆状态字
		$("#hosplogintime").html(data.doclogintime);//上次登陆时间
		
		$("#hospname").html(data.hospname);//医院名称
		$("#hospregidcard").html(data.hospregidcard);//
		$("#hospphone").html(data.hospphone);//
		$("#hosplevelname").html(data.hosplevelname);//
		$("#address1").html(data.hospadrprovince+","+data.hospadrcity);//所在地址
		$("#address2").html(data.hospadrarea+","+data.hospadrother);//所在地址
		$("#hospabs").html(data.hospabs);
		$("#hospfeature").html(data.hospfeature);
		for(var i=0;i<data.hosppraclicense.length;i++){
			var hosppraclicense=data.hosppraclicense[i];
			var photoname="注册医院执业许可证照片*"+Number(i+1);
			if(hosppraclicense!=""){
				AddPhotoPanel(hosppraclicense,photoname);
			}
		}
		for(var i=0;i<data.hospregdocquacer.length;i++){
			var hospregdocquacer=data.hospregdocquacer[i];
			var photoname="注册人医师资格证照片*"+Number(i+1);
			if(hospregdocquacer!=""){
				AddPhotoPanel(hospregdocquacer,photoname);
			}
		}
		for(var i=0;i<data.hosplegalcer.length;i++){
			var hosplegalcer=data.hosplegalcer[i];
			var photoname="医院法人证明照片*"+Number(i+1);
			if(hosplegalcer!=""){
				AddPhotoPanel(hosplegalcer,photoname);
			}
		}
		for(var i=0;i<data.hosporgcodecer.length;i++){
			var hosporgcodecer=data.hosporgcodecer[i];
			var photoname="质监部门机构代码证*"+Number(i+1);
			if(hosporgcodecer!=""){
				AddPhotoPanel(hosporgcodecer,photoname);
			}
		}
    }
    function AddPhotoPanel(data,photoname){
    	$("#photoPanel").append('<div class="col-sm-6">'+
		    	'<div class="panel panel-default">'+
		    	'<div class="panel-heading">'+
	            	'<h5 class="panel-title">'+
	                	'<a data-toggle="collapse" data-parent="#accordion" href="javscript:;">'+photoname+'</a>'+
	            	'</h5>'+
	            '</div>'+
	     		'<div id="" class="panel-collapse collapse in">'+
                	'<div class="panel-body">'+
                       	'<a class="fancybox" target="_blank" href="'+data+'" title="'+photoname+'">'+
				        	'<img alt="image" src="'+data+'" style="width:320px;height:180px;"/>'+
					    '</a> '+
            		'</div>'+
            	'</div>'+
           ' </div>'+
    	'</div>');
    }
    function words_deal(id){
    	var value=$('#'+id).val().length;
        if(value>150){
        	var num=$('#'+id).val().substr(0,150);
        	$('#'+id).val(num);
        	//alert("超过字数限制，多出的字将被截断！" );
        }
    }
	</script>
	<script type="text/javascript">
		$(function () {
			$('#startdatetime').datetimepicker({  
				format: 'YYYY-MM-DD',  
				locale: moment.locale('zh-cn')  
			});
			$('#enddatetime').datetimepicker({  
				format: 'YYYY-MM-DD',  
				locale: moment.locale('zh-cn')  
			});
			$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Patient/loadcity.action",
    			async: true,
    			data:"cityparentcode=0",
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				var datalist = data.list;
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#hospadrprovince1').append("<option value='" + datalist[i].citycode + "' >" + datalist[i].cityname + "</option>");  
                        }
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(){
        			$.alert("加载省失败!!!");
        		}
    		})
    		$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/loadhosplevel.action",
    			async: true,
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				var datalist = data.list;
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#hosplevel1').append("<option value='" + datalist[i].hosplevelname + "' >" + datalist[i].hosplevelname + "</option>");  
                        }
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(){
        			$.alert("加载所属医院级别失败!!!");
        		}
    		})
		});
		function loadcity(){
			var cityparentcode = $("#hospadrprovince1").val();
			if(cityparentcode==0){
				$("#hospadrcity1").empty();  
                $("#hospadrarea1").empty();
                $('#hospadrcity1').append("<option value='0' selected='selected' >" + '---请选择市---' + "</option>");  
                $('#hospadrarea1').append("<option value='0' selected='selected' >" + '---请选择区（县）---' + "</option>");  
			}else{
				$("#hospadrcity1").empty();  
                $("#hospadrarea1").empty();
                $.ajax({  //页面首加载省下拉框数据
                    type: "post",  
                    url: "${pageContext.request.contextPath}/Main/Patient/loadcity.action",
            		async: true,
                    data:"cityparentcode="+cityparentcode,
                    success: function (data) {
                    	var datalist = data.list;
                    	$('#hospadrcity1').append("<option value='0' selected='selected' >" + '---请选择市---' + "</option>");  
                        $('#hospadrarea1').append("<option value='0' selected='selected' >" + '---请选择区（县）---' + "</option>");  
                        for (var i = 0; i < datalist.length; i++) {
                            $('#hospadrcity1').append("<option value='" + datalist[i].citycode + "' >" + datalist[i].cityname + "</option>");  
                        }  
                    },  
                    error: function () {  
                        $.alert("加载市失败!!!");  
                    }  
                });
			}
		}
		function loadarea(){
			var cityparentcode = $("#hospadrcity1").val();
			if(cityparentcode==0){
                $("#hospadrarea1").empty();
                $('#hospadrarea1').append("<option value='0' selected='selected' >" + '---请选择区（县）---' + "</option>");  
			}else{
                $("#hospadrarea1").empty();
                $.ajax({  //页面首加载省下拉框数据
                    type: "post",  
                    url: "${pageContext.request.contextPath}/Main/Patient/loadcity.action",
            		async: true,
                    data:"cityparentcode="+cityparentcode,
                    success: function (data) {
                    	var datalist = data.list;
                        $('#hospadrarea1').append("<option value='0' selected='selected' >" + '---请选择区（县）---' + "</option>");  
                        for (var i = 0; i < datalist.length; i++) {
                            $('#hospadrarea1').append("<option value='" + datalist[i].citycode + "' >" + datalist[i].cityname + "</option>");  
                        }  
                    },  
                    error: function () {  
                        $.alert("加载县失败!!!");  
                    }  
                });
			}
		}
	</script>
</body>
</html>